/*
 *  CS202 - Spring 2009">
 *  Professor: Dr. Michael Peterson">
 *  Student: Deylo Woo (dwoo711@gmail.com) ">
 */
package project_4;

import javax.swing.*;
import java.awt.*;
import java.util.LinkedList;

public class GamePanel extends JPanel {

    private GridLayout _grid;
    private LinkedList<Card> _cards;

    public GamePanel() {
        super();
        this.repaint();
        this.setVisible(true);

        _grid = new GridLayout(4, 5);
        setLayout(_grid);
        _cards = new LinkedList<Card>();

        for (Integer x = 0; x < 20; x++) {
            Card _card = new Card(x.toString());
            _cards.add(_card);
        //JButton _jbutton = new JButton();
        //_jbutton.setIcon(new ImageIcon("images/t1.jpg"));
        // _jbutton.setPreferredSize(new Dimension(40, 40));
        //_jbutton.setRolloverIcon(new ImageIcon("images/t1.jpg"));
        //_card.setJbutton(_jbutton);
        }

        //Rand place
        int[] _clist = new int[20];
        int _count = 0;
        while(_count < 20){
            boolean _inList = false;
            int _rand = (int) (Math.random() * 19);
            for(int y = 0; y < 20; y++){
                if(_rand == _clist[y]){
                   _inList = true;
                }
            }
            if(_inList == false){
                _clist[x] = _rand;
                add(_cards.get(x).getJbutton());
            }
        }

    }
}
